package com.bestcem.xm.ticket.controller.param.ticket.config.createParam;

import com.bestcem.xm.ticket.constant.ColumnConstant;
import com.bestcem.xm.ticket.entity.mongo.TicketFlow;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.annotation.Nullable;
import java.io.Serializable;

/**
 * @author zq.ding <zq.ding@idiaoyan.com>
 * @version v1.0
 * @date 2021/9/8 16:58
 */

@NoArgsConstructor
@AllArgsConstructor
@Data
public class OptionParam implements Serializable {
    private static final long serialVersionUID = 2808726620840986656L;

    /**
     * id
     */
    @JsonProperty(value = ColumnConstant.TicketFlow.FollowConfig.Option.ID)
    private String id;

    /**
     * title
     */
    @JsonProperty(value = ColumnConstant.TicketFlow.FollowConfig.Option.TITLE)
    private String title;

    /**
     * role_index
     */
    @JsonProperty(value = ColumnConstant.TicketFlow.FollowConfig.Option.ROLE_INDEX)
    private String roleIndex;

    /**
     * roleType
     */
    @JsonProperty(value = ColumnConstant.TicketFlow.FollowConfig.Option.ROLE_TYPE)
    private Integer roleType;

    @Nullable
    public static TicketFlow.FollowConfig.Option paramToEntity(OptionParam param) {
        if (param == null) {
            return null;
        }
        TicketFlow.FollowConfig.Option option = new TicketFlow.FollowConfig.Option();
        option.setId(param.getId());
        option.setTitle(param.getTitle());
        option.setRoleIndex(param.getRoleIndex());
        option.setRoleType(param.getRoleType());
        return option;
    }

}

